﻿using MiniFox.Components;
using MiniFox.Infrastructure;
using MiniFox.Platform.Applications;
using MiniFox.Platform.Applications.Auth;
using Sys.Core.Models.Queries;
using Sys.Core.Models.VO;
using Sys.Core.Providers;

namespace Sys.Core.Services
{
    [AutoResolve]
    public class DispatcherService : ApiServiceBase, IDispatcherService
    {
        public DispatcherService(SystemPrincipal principal) : base(principal)
        {
        }
        [AutoWired]
        protected IDispatcherProvider Provider { get; set; }

        public MailFailItemVo FailItem(string messageId)
        {
            var item = this.Provider.FailItem(messageId);
            if (item == null) return null;
            return item;
        }

        public ResultObject<IEnumerable<MailFailItemVo>> FailQuery(PagedQueryObject<MailQuery> request)
        {
            return this.Provider.FailQuery(request);
        }

        public MailSentItemVo SentItem(string messageId)
        {
            var item = this.Provider.SentItem(messageId);
            if (item == null) return null;
            return item;
        }

        public ResultObject<IEnumerable<MailSentItemVo>> SentQuery(PagedQueryObject<MailQuery> request)
        {
            return this.Provider.SentQuery(request);
        }

        public MessageVo MessageItem(string messageId)
        {
            var item = this.Provider.MessageItem(messageId);
            if (item == null) return null;
            return item;
        }

        public ResultObject<IEnumerable<MessageVo>> MessageQuery(PagedQueryObject<MessageQuery> request)
        {
            return this.Provider.MessageQuery(request);
        }

    }
}
